package com.cskaoyan.shopping.service.impl;

import com.cskaoyan.shopping.converter.ProductCateConverter;
import com.cskaoyan.shopping.dal.entitys.ItemCat;
import com.cskaoyan.shopping.dal.persistence.ItemCatMapper;
import com.cskaoyan.shopping.dto.ProductCateDto;
import com.cskaoyan.shopping.service.IProductCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author tan
 * @date 2023年01月10日 23:22
 */
@Service
public class IProductCateServiceImpl implements IProductCateService {
    @Autowired
    ItemCatMapper itemCatMapper;
    @Autowired
    ProductCateConverter productCateConverter;
    @Override
    public List<ProductCateDto> getAllProductCate(String sort) {
        Example example = new Example(ItemCat.class);
        example.orderBy("sortOrder").asc();
        List<ItemCat> itemCats = itemCatMapper.selectByExample(example);
        List<ProductCateDto> productCateDtos = productCateConverter.items2Dto(itemCats);
        return productCateDtos;
    }
}
